#!/usr/bin/perl

@array=([],[]);
for($i=0; $i<10; $i++){
	for($j=0; $j<10; $j++){
		$array[$i][$j]=" . ";
	}
}
foreach $coordinates(@ARGV){

	$start_x=substr($coordinates, 0, 1);
	$start_y=substr($coordinates, 1, 1);
	$finish_x=substr($coordinates, 2, 1);
	$finish_y=substr($coordinates, 3, 1);

	if(($start_x!=$finish_x)&&($start_y!=$finish_y)){
		print "incorrect data!!!\n";
		exit(0);
	}
	if((($start_x-$finish_x)>3)||(($start_y-$finish_y)>3)){
		print "incorrect size!!!\n";
		exit(0);			
	}

	for($i=$start_x; $i<=$finish_x; $i++){
		for($j=$start_y; $j<=$finish_y; $j++){
			if($array[$i][$j] eq " X "){
				print "incorrect position of ships!!!\n";
				exit(0);
				}
			$array[$i][$j]=" X ";
		}
	}
}		
print "  0  1  2  3  4  5  6  7  8  9\n";
for($i=0; $i<10; $i++){
	print "$i";
	for($j=0; $j<10; $j++){
		print "$array[$i][$j]";
	}
print "\n";
}
